//
//  LGFriendViewController.m
//  ligenyun
//
//  Created by apple on 2018/3/24.
//  Copyright © 2018年 stoneobs@icloud.com. All rights reserved.
//

#import "LGFriendViewController.h"
#import "LGFriendTableViewCell.h"
#import "LGFriendDetailViewController.h"

@interface LGFriendViewController ()
@property(nonatomic, strong) NSArray     *dataSouce;
@end

@implementation LGFriendViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"亲友";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --SubView
- (void)configSubView{
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 30)];
    header.backgroundColor = TM_backgroundColor;
    
    STButton * searchButton = [[STButton alloc] initWithFrame:CGRectMake(15, 15, UIScreenWidth - 30, 44)
                                                      title:@"  搜索论坛"
                                                 titleColor:SecendTextColor
                                                  titleFont:15
                                               cornerRadius:0
                                            backgroundColor:nil
                                            backgroundImage:nil
                                                      image:nil];
    [searchButton st_setBorderWith:1 borderColor:SecendTextColor cornerRadius:2];
    [header addSubview:searchButton];
    STButton * aButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)
                                                      title:nil
                                                 titleColor:nil
                                                  titleFont:0
                                               cornerRadius:0
                                            backgroundColor:nil
                                            backgroundImage:nil
                                                      image:[UIImage imageNamed:@"搜索"]];
    aButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    aButton.right = searchButton.width;
    aButton.userInteractionEnabled = NO;
    [searchButton addSubview:aButton];
    
    STButton * addButton = [[STButton alloc] initWithFrame:CGRectMake(0, searchButton.bottom  + 15, UIScreenWidth, 44)
                                                      title:@"新好友"
                                                 titleColor:SecendTextColor
                                                  titleFont:15
                                               cornerRadius:0
                                            backgroundColor:[UIColor whiteColor]
                                            backgroundImage:nil
                                                      image:[UIImage imageNamed:@"亲友_添加10"]];
    addButton.imageEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0);
    addButton.titleEdgeInsets = UIEdgeInsetsMake(0, 15 + 10, 0, 0);
    [header addSubview:addButton];
    header.height = addButton.bottom;
    self.tableView.tableHeaderView = header;
    
    
}
#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return [LGFriendTableViewCell cellHeight];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return [UIView new];
}
- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    return @"A";
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    LGFriendTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[LGFriendTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
//    cell.textLabel.text = [NSString stringWithFormat:@"%lu",indexPath.row];
//    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//    cell.imageView.image = [UIImage imageNamed:@"1"];
//    cell.textLabel.text = @"安达市大所多";
    
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.navigationController pushViewController:[LGFriendDetailViewController new] animated:YES];
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

@end
